package net.WMisiedjan.RedstoneEffects;

import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;

public class RedstoneEffectsPermissions {

	private final transient PermissionHandler permissionHandler;
	public transient boolean opPermissions = false;

	public RedstoneEffectsPermissions(final Plugin permissionsPlugin) {
		permissionHandler = ((Permissions) permissionsPlugin).getHandler();
	}
	
	public RedstoneEffectsPermissions(final boolean permissionsPlugin) {
		permissionHandler = null;
		opPermissions = true;
	}
	
	public RedstoneEffectsPermissions() {
		permissionHandler = null;
		opPermissions = true;
	}

	public boolean hasPermission(final Player base, final String node)
	{
		if(opPermissions)
		{
			return base.isOp();
		}
		else
		{
			return permissionHandler.permission(base, node);
		}
	}
}
